﻿//#define _CRT_SECURE_NO_WARNINGS  1
////一定要动手，例子不管多么简单，建议至少自己手敲一遍看看是否理解了里头的细枝末节。
////一定要学会思考，思考为什么要这样，而不是那样。还要举一反三地思考
//#include<string>
//#include<iostream>
//using namespace std;
////抽象CPU类
//class CPU {
//public:
//	virtual void handle() = 0;
//};
////抽象内存类
//class Memory {
//public:
//	virtual void storage() = 0;
//};
////抽象显卡类
//class videocard {
//public:
//	virtual void image() = 0;
//};
////class Computer {
////private:
////	CPU* _cpu;
////	Memory* _mem;
////	videocard* _vid;
////public:
////	Computer(CPU* cpu, Memory* mem, videocard* vid) {
////		_cpu = cpu;
////		_mem = mem;
////		_vid = vid;
////	}
////	void dowork()
////	{
////		_cpu->handle();
////		_mem->storage();
////		_vid->image();
////	}
////	~Computer()
////	{
////		if (_cpu != nullptr)
////		{
////			delete _cpu;
////			_cpu = NULL;
////		}
////
////		if (_mem != nullptr)
////		{
////			delete _mem;
////			_mem = NULL;
////		}
////
////		if (_vid != nullptr)
////		{
////			delete _vid;
////			_vid = NULL;
////		}
////		
////	}
////
////};
//
//class Computer {
////private:
////	CPU* _cpu;
////	Memory* _mem;
////	videocard* _vid;
//public:
//	Computer(CPU& cpu, Memory& mem, videocard& vid) {
//		cpu.handle();
//		mem.storage();
//		vid.image();
//	}
//	/*void dowork()
//	{
//		_cpu->handle();
//		_mem->storage();
//		_vid->image();
//	}*/
//	~Computer()
//	{
//		/*if (_cpu != nullptr)
//		{
//			delete _cpu;
//			_cpu = NULL;
//		}
//
//		if (_cpu != nullptr)
//		{
//			delete _mem;
//			_mem = NULL;
//		}
//
//		if (_cpu != nullptr)
//		{
//			delete _vid;
//			_vid = NULL;
//		}
//		*/
//	}
//
//};
//
//class IntelCPU :public CPU {
//public:
//	virtual void handle()
//	{
//		cout << "intel cup开始运行！" << endl;
//	}
//};
//class IntelMemory :public Memory {
//public:
//	virtual void storage()
//	{
//		cout << "intel Memory开始运行！" << endl;
//	}
//};
//class Intelvideocard :public videocard {
//public:
//	virtual void image()
//	{
//		cout << "intelvideocard开始运行！" << endl;
//	}
//}; 
//class lenovoCPU :public CPU {
//public:
//	virtual void handle()
//	{
//		cout << "lenovoCPU开始运行！" << endl;
//	}
//};
//class lenovoMemory :public Memory {
//public:
//	virtual void storage()
//	{
//		cout << "lenovoMemory开始运行！" << endl;
//	}
//};
//class lenovovideocard :public videocard {
//public:
//	virtual void image()
//	{
//		cout << "lenovovideocard开始运行！" << endl;
//	}
//};
//void test()
//{
//	////选择电脑硬件
//	//CPU* cpu = new IntelCPU;
//	//Memory* mem = new IntelMemory;
//	//videocard* vid = new Intelvideocard;
//	////创建第一个电脑
//	//Computer* computer = new Computer(cpu, mem, vid);
//	////电脑开始工作
//	//computer->dowork();
//	//delete computer;
//	//cout << "---------------------------" << endl;
//	//computer = new Computer(new lenovoCPU,new lenovoMemory,new lenovovideocard);
//	//computer->dowork();
//	//delete computer;
//	cout << "-------------------------------" << endl;
//	lenovoCPU l1;
//	lenovoMemory l2;
//	lenovovideocard l3;
//	Computer* computer = new Computer(l1, l2, l3);
//
//}
//int main()
//{
//	test();
//	return 0;
//}